import { FC, useEffect, useRef, useState } from "react";
import styles from "./index.module.less";
// import { date } from '@supcon/supcon-5t-utils';

const Header: FC = () => {
  // const context = useContext(BigScreenContext);
  // const jumpFunc = useJumpFun();
  const [timeInfo, setTimeInfo] = useState({
    time: "",
    date: "",
    week: "",
  });

  const settimeoutTime = useRef<number>(60);

  const getDate = () => {
    const date = new Date();
    const week = [
      "星期日",
      "星期一",
      "星期二",
      "星期三",
      "星期四",
      "星期五",
      "星期六",
    ];
    const year = date.getFullYear();
    const month = date.getMonth() + 1;
    const day = date.getDate();
    const hour = date.getHours();
    // const minute = date.getMinutes();
    const minute = date.getUTCMinutes();
    const secound = date.getSeconds();
    const showMinute = minute < 10 ? "0" + minute : minute;

    setTimeInfo({
      time: `${hour}:${showMinute}`,
      date: `${year}年${month}月${day}日`,
      week: week[date.getDay()],
    });
    settimeoutTime.current = 60 - secound;

    setTimeout(() => {
      getDate();
    }, settimeoutTime.current * 1000);
  };

  // const jumpClick = () => {
  //   const { currentKey } = context;
  //   // if (currentKey === "stabilityAssessment") {
  //   //   jumpFunc("/autofactory/PerformanceEvaluation", true);
  //   //   return;
  //   // }
  //   // if (currentKey === "dynamicRisk") {
  //   //   jumpFunc("/autofactory/DynamicRiskEvaluation", true, false);
  //   //   return;
  //   // }
  //   // if (currentKey === "valve") {
  //   //   jumpFunc(
  //   //     "/autofactory/GeneralWorkEvaluation?groupKey=稳定性评估",
  //   //     true,
  //   //     false
  //   //   );
  //   //   return;
  //   // }
  //   // if (currentKey === "technologyAnomaly") {
  //   //   jumpFunc(
  //   //     "/autofactory/GeneralWorkEvaluation?groupKey=工艺异常预警",
  //   //     true,
  //   //     false
  //   //   );
  //   //   return;
  //   // }
  //   // if (currentKey === "controlPerformance") {
  //   //   jumpFunc(
  //   //     "/autofactory/GeneralWorkEvaluation?groupKey=控制性能评估",
  //   //     true,
  //   //     false
  //   //   );
  //   //   return;
  //   // }
  //   // if (currentKey === "equipmentReliability") {
  //   //   jumpFunc(
  //   //     "/autofactory/GeneralWorkEvaluation?groupKey=执行可靠性评估",
  //   //     true,
  //   //     false
  //   //   );
  //   //   return;
  //   // }
  //   // if (currentKey === "assetReliability") {
  //   //   jumpFunc("/autofactory/AssetsEvaluation", true, false);
  //   //   return;
  //   // }
  //   // if (currentKey === "dataCredibility") {
  //   //   jumpFunc("/autofactory/CredibleEvaluation/CredibleTask", true, false);
  //   //   return;
  //   // }
  //   if (currentKey === "main") {
  //     jumpFunc("/autofactory/sysHomeManage", true, false);
  //     return;
  //   }
  //   message.error("当前模块暂未开发或者暂未配置跳转页面");
  // };

  useEffect(() => {
    getDate();
  }, []);

  return (
    <>
      <div className={styles["header"]}>
        {/* <div className={styles['header-title']}>无人值守评估系统</div> */}
        <div className={styles["header-title"]}>
          <div className={styles["font"]}></div>
        </div>
        <div className={styles["header-time-area"]}>
          {timeInfo.date} {timeInfo.week} {timeInfo.time}
          {/* <div className={styles['time']}>{timeInfo.time}</div>
          <div className={styles['date-info']}>
            <span className={styles['week']}>{timeInfo.week}</span>
            <br />
            <span className={styles['date']}>{timeInfo.date}</span>
          </div> */}
          {/* <span
            style={{ fontSize: 14, marginLeft: 8, cursor: "pointer" }}
            onClick={jumpClick}
          >
            <SettingOutlined />
          </span> */}
        </div>
      </div>
    </>
  );
};

export default Header;
